/**
 * Create by cheese znnozomi@163.com
 * 2018/5/5
 */


/*对象解构*/
let node = {
    loc: {
        start: {
            line: 1,
            column: 5
        }
    }
};

let {
    loc,
    loc: { start },
    loc: { start: { line } }
} = node;

console.log(line);
console.log(loc);
console.log(start);

let obj = {};
let arr = [];

({ foo: obj.prop, bar: arr[0] } = { foo: 123, bar: true });

console.log(obj);
console.log(arr);

let _out = '我是全局变量';

{
    let _in = '我是局部变量';
    console.log(_out);
}

{
    // console.log(_in);  //not defined
}

{

    let t = f();

    console.log(t * t + 1);

    function f() {

        return 2;
    };
}

console.log(f());


{
    console.log(''.charAt(0))
}

/*
内建函数
 */
{
    let s = new String('hello world');
    console.log(s);
    console.log(typeof s);
    console.log(s instanceof String);
    console.log(s.toString());
    console.log(Object.prototype.toString.call(s));

    let obj = new Object();
    console.log(obj);
    console.log(Object.prototype);

/*let _number = new Number(2);
console.log(_number.toFixed());
console.log(new Number());*/
}